home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0115_Function Queues.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  1KB  |  49 lines

  1. {
  2. > Ok I am playing and trying to get a unit to do this stuff
  3. > AddFunction( fn : string);  (* add a function name to the loop *)
  4. > RemoveFuction( fn : string); ReadyLoop; StartLoop; EndLoop; ClearLoop;
  5. > basicly the statloop will run ALL the AddFunction'ed functoins til the
  6. > code hits a EndLoop;
  7.  
  8. You could have an array of procedures/functions... thus:
  9. }
  10.  
  11. Type
  12.  MyFunction:Function (X,Y,Z:Byte; R:Real; S:String; Var W:Word):String;
  13.  {Create exactly what you need. You probibly only want function:Boolean or
  14.   something}
  15.  
  16. Var
  17.  Funcs:Array[1..20] Of MyFunction;
  18.  FuncsCount:Byte;
  19.  
  20. {$F+}
  21. Function Example_My_Func(X,Y,Z:Byte; R:Real; S:String; Var W:Word):String;
  22. Begin
  23.  {Any code here!}
  24.  Example_My_Func:=S+'!';
  25. End;
  26. {$F-}
  27.  
  28. Procedure Add_Function(Func:MyFunction);
  29. Begin
  30.  Inc(FuncsCount);
  31.  Funcs[FuncsCount]:=Func;
  32. End;
  33.  
  34. Procedure Call_All_Funcs;
  35. Var
  36.  L:Byte;
  37.  A_Word:Word;
  38. Begin
  39.  For L:=1 To FuncsCount Do
  40.   Writeln(Funcs[FuncsCount](1,2,3,1.55,'Yay',A_Word));
  41. End;
  42.  
  43. Begin
  44.  FuncsCount:=0; {Initialisation}
  45.  Add_Function(@Example_My_Func);   {<= Not sure if the '@' symbol is needed}
  46.  Call_All_Funcs;
  47.   {Dont need to remove them or anything.}
  48. End.
  49.